/** 系统管理模块 **/

import http from "@/api";
import Qs from 'qs'; 

const { APP_USER_URL } = window.config;

/** 用户管理模块 **/

// 查询用户是否存在
export const queryUserIsExist = (params) => {
    return http.post(`${APP_USER_URL}/user/queryUserIsExist`, Qs.stringify(params)); 
};

// 查询手机号是否存在
export const queryPhoneIsExist = (params) => {
    return http.post(`${APP_USER_URL}/user/queryPhoneIsExist`, Qs.stringify(params)); 
};

// 获取用户列表
export const getUserList = (params) => {
    return http.post(`${APP_USER_URL}/user/queryUserListForPage`, params); 
};

// 获取用户详情信息
export const getUserDetail = (params) => {
    return http.post(`${APP_USER_URL}/user/queryUser`, Qs.stringify(params)); 
};

// 用户新增
export const addUser = (params) => {
    return http.post(`${APP_USER_URL}/user/insertUser`, params); 
};

// 用户编辑
export const editUser = (params) => {
    return http.post(`${APP_USER_URL}/user/editUser`, params); 
};

// 用户删除
export const deleteUser = (params) => {
    return http.post(`${APP_USER_URL}/user/deleteUser`, Qs.stringify(params)); 
};

/** 角色管理模块 **/

// 获取用户角色列表
export const getUserRoleList = (params) => {
    return http.post(`${APP_USER_URL}/user/getRoleListOfMerge`, params);
};

// 获取角色列表
export const getRoleList = (params) => {
    return http.post(`${APP_USER_URL}/role/queryRoleListForPage`, params);
};

// 新增用户角色
export const addRole = (params) => {
    return http.post(`${APP_USER_URL}/role/insertRole`, Qs.stringify(params));
};

// 编辑用户角色
export const editRole = (params) => {
    return http.post(`${APP_USER_URL}/role/updateRole`, Qs.stringify(params));
};

// 删除用户角色
export const deleteRole = (params) => {
    return http.post(`${APP_USER_URL}/role/deleteRole`, Qs.stringify(params));
};

// 查询用户角色是否存在
export const queryRoleIsExist = (params) => {
    return http.post(`${APP_USER_URL}/role/queryRoleIsExist`, Qs.stringify(params));
};

// 获取权限树
export const getPermissionTree = (params) => {
    return http.post(`${APP_USER_URL}/permission/getPermissionTree`, Qs.stringify(params));
};

// 角色权限查询
export const queryRole = (params) => {
    return http.post(`${APP_USER_URL}/role/queryRole`, Qs.stringify(params));
};

/** 字典管理模块 **/

// 获取字典列表
export const getDictionaryList = (params) => {
    return http.post(`${APP_USER_URL}/dictionary/queryDictionaryTypeListForPage`, params);
};

// 字典新增
export const addDictionary = (params) => {
    return http.post(`${APP_USER_URL}/dictionary/insertDictionaryType`, Qs.stringify(params));
};

// 查询字典码是否存在
export const queryDictionaryIsExist = (params) => {
    return http.post(`${APP_USER_URL}/dictionary/queryDictionaryTypeIsExist`, Qs.stringify(params));
};

// 字典编辑
export const editDictionary = (params) => {
    return http.post(`${APP_USER_URL}/dictionary/updateDictionaryType`, Qs.stringify(params));
};

// 字典删除
export const deleteDictionary = (params) => {
    return http.post(`${APP_USER_URL}/dictionary/deleteDictionaryType`, Qs.stringify(params));
};

// 获取字典项数据列表
export const getDictionaryItemList = (params) => {
    return http.post(`${APP_USER_URL}/dictionary/queryDictionaryItemListForPage`, params);
};

// 字典项数据新增
export const addDictionaryItem = (params) => {
    return http.post(`${APP_USER_URL}/dictionary/insertDictionaryItem`, Qs.stringify(params));
};

// 字典项数据编辑
export const editDictionaryItem = (params) => {
    return http.post(`${APP_USER_URL}/dictionary/updateDictionaryItem`, Qs.stringify(params));
};

// 字典项数据删除
export const deleteDictionaryItem = (params) => {
    return http.post(`${APP_USER_URL}/dictionary/deleteDictionaryItem`, Qs.stringify(params));
};